package com.naruto.thinkmgr.serviceimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.naruto.thinkmgr.bean.*;
import com.naruto.thinkmgr.mapper.UserMapper;
import com.naruto.thinkmgr.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;

@Service(version = "1.0.0")
public class UserServiceImpl implements UserService {

    private Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Override
    public Page<User> queryUserPage() {
        logger.info("provider queryUserPage");
        return new Page<User>();
    }

    @Override
    public void addUser(User newUser) {

    }

    @Override
    public User getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    @Override
    public User getUserById(int userId) {
        return userMapper.getUserById(userId);
    }

    @Override
    public void updatePassword(User dbUser) {
        this.userMapper.updatePassword(dbUser);
    }

    @Override
    public Collection<Role> getAllRolesByUserId(int userId) {
        return this.userMapper.getAllRolesByUserId(userId);
    }

    @Override
    public Collection<Permission> getAllPermissionsByUserId(int userId) {
        return this.userMapper.getAllPermissionsByUserId(userId);
    }

    @Override
    public Page<User> queryUserByPage(PageParm pageParm, User user) {
        return this.userMapper.queryUserByPage(pageParm,user);
    }

}
